package com.jcl.recruit.crawler.mapper;

import com.jcl.recruit.crawler.model.CrawlerDownloadResumeFeedback;
import com.jcl.recruit.mapper.SqlMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName CrawlerDownloadResumeFeedbackMapper

 * @Author yyliu
 * @Date 2018/10/22 14:27
 * @Version 1.0
 **/
public interface CrawlerDownloadResumeFeedbackMapper extends SqlMapper {

    @Select({
            "<script>",
            "select * from crawler_download_resume_feedback ",
            "<where>",
            "<if test=\"null != corpCode\">",
            " and corp_code = #{corpCode}",
            "</if>",
            "<if test=\"null != resumeId\">",
            " and resume_id = #{resumeId}",
            "</if>",
            "</where>",
            "</script>"
    })
    List<CrawlerDownloadResumeFeedback> findListByResumeId(@Param("corpCode") String corpCode,
                                                           @Param("resumeId") Integer resumeId);


    @Select({
            "<script>",
            "select * from crawler_download_resume_feedback ",
            "<where>",
            "<if test=\"null != corpCode\">",
            " and corp_code = #{corpCode}",
            "</if>",
            "<if test=\"null != crawlerId\">",
            " and crawler_id = #{crawlerId}",
            "</if>",
            "</where>",
            "</script>"
    })
    List<CrawlerDownloadResumeFeedback> findListByCrawlerId(@Param("corpCode") String corpCode,
                                                            @Param("crawlerId") Integer crawlerId);

    @Insert({
            "insert into crawler_download_resume_feedback ",
            "(crawler_id, resume_id, corp_code, status, create_time) ",
            "values ( ",
            "#{crawlerId, jdbcType=INTEGER}, #{resumeId, jdbcType=INTEGER}, #{corpCode, jdbcType=VARCHAR}, ",
            "#{status, jdbcType=INTEGER}, #{createTime, jdbcType=TIMESTAMP}",
            ")"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int add(CrawlerDownloadResumeFeedback crawlerDownloadResumeFeedback);


}
